(function() {
  var msgData, onceKey,
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  msgData = {};

  onceKey = ['loginInfo'];

  this.msg = function(key, val) {
    if (val == null) {
      val = null;
    }
    if (val === null) {
      if (__indexOf.call(onceKey, key) >= 0 && typeof msgData[key] !== 'undefined') {
        delete msgData[key];
      }
      return msgData[key];
    } else {
      return msgData[key] = val;
    }
  };

  chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
    var finded, key, ret;
    ret = {};
    finded = false;
    if (request) {
      for (key in request) {
        if (typeof msgData[key] !== 'undefined') {
          ret[key] = msgData[key];
          finded = true;
          if (__indexOf.call(onceKey, key) >= 0) {
            delete msgData[key];
          }
        }
      }
    }
    if (finded) {
      return sendResponse(ret);
    }
  });

  noProxy();

}).call(this);
